package com.uzhie.jt808;

import io.netty.channel.Channel;

/**
 * Created by TangFei on 2018/7/17.
 */
public class JT808Session {

    // 连接通道
    private Channel channel;
    // 协议类型 2011 2013
    private PROTO proto;
    // 驾驶员姓名
    private String driverName;

    // 过期时间 毫秒时间戳
    private long expireAt;

    public JT808Session() {
    }

    public JT808Session(Channel channel, long expireTime) {
        this.channel = channel;
        this.expireAt = System.currentTimeMillis() + expireTime;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public long getExpireAt() {
        return expireAt;
    }

    public void setExpireAt(long expireAt) {
        this.expireAt = expireAt;
    }

    public void refreshExpireAt(long expireTime) {
        this.expireAt = System.currentTimeMillis() + expireTime;
    }

    public String getDriverName() {
        return driverName;
    }

    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    public PROTO getProto() {
        return proto;
    }

    public void setProto(PROTO proto) {
        this.proto = proto;
    }

    /**
     * 设备协议类型枚举
     */
    public enum PROTO {
        // JT808-2011
        PROTO_2011("2011"),
        // JT808-2013
        PROTO_2013("2013");
        private String protoStr;

        PROTO(String protoStr) {
            this.protoStr = protoStr;
        }

        public String getProtoStr() {
            return protoStr;
        }
    }

}
